<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<script type="text/javascript" src="highslide/highslide-with-gallery.js"></script>
<link rel="stylesheet" type="text/css" href="highslide/highslide.css" />

<script type="text/javascript">
	hs.graphicsDir = 'highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.wrapperClassName = 'dark borderless floating-caption';
	hs.fadeInOut = true;
	hs.dimmingOpacity = .75;
	hs.showCredits = false;

	// Add the controlbar
	if (hs.addSlideshow) hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			opacity: .6,
			position: 'bottom center',
			hideOnMouseOut: true
		}
	});
</script>

<?php
include 'init.php';
include "./include/membersite_config.php";

if(!$fgmembersite->CheckLogin())
{
    $fgmembersite->RedirectToURL("index.php");
    exit;
}

if (!isset($_GET['album_id']) || empty($_GET['album_id']) || !isset($_GET['Eimage_id']) || 
    empty($_GET['Eimage_id']) || album_check($_GET['album_id']) === false) {
  header('Location: albums.php');
  exit();
}

include 'template/header.php';

$album_id = $_GET['album_id'];
$album_data = album_data($album_id, 'name', 'description');
$Eimage_id = $_GET['Eimage_id'];
$Eimage_keywords = image_data($album_id, $Eimage_id, 'image_keywords');

echo '<h3>', $album_data['name'], '</h3><p>', $album_data['description'], '</p>';

$strongF = "<strong>";
$strongB = "</strong>";

$images = get_images($album_id);

?>

</head>

<body>

<!--
	3) Put the thumbnails inside a div for styling
-->
<div class="highslide-gallery">
<?php

if (empty($images)) {

	echo 'There are no images in this album';

} else {
	
	foreach ($images as $image) {
	  if ($Eimage_id == $image['id']) {
	  echo'<a href="uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '" 
	           class="highslide" onclick="return hs.expand(this)">
	         <img src="uploads/thumbs/', $image['album'], '/', $image['id'], '.', $image['ext'], '" 
	              alt="Highslide JS" title="Uploaded ', date('D M Y / h:i', $image['timestamp']), '" />
	          <div class="highslide-caption"> Keywords: &nbsp', $image['keywords'],' </div>';
	  }
	}
	//print_r('uploads/'.$album_id.'/'.$image_id.'.'.$image_ext);
}

?>
</div>

<?php

if (isset($_POST['image_keys'])) {
  $image_keys = $_POST['image_keys'];
  //print_r = $image_keywords;
  
  $errors = array();
  
  if (empty($image_keys)) {
    $errors[] = ''.$strongF.'!!! keywords required !!!'.$strongB.'';
  } else {
      
      if (strlen($image_keys) > 70) {
        $errors[] = ''.$strongF.'!!! Sorry! You cannot tag too much keywords !!!'.$strongB.'';
     }
   }
  
  if (!empty($errors)) {
    foreach ($errors as $error) {
      echo $error, '<br />';
    }
  } 
   else {
    edit_image($album_id, $Eimage_id, $image_keys);
    header('Location: view_album_test.php?album_id='.$album_id);
    exit();
   }

}
?>


<form action="?album_id=<?php echo $album_id; ?>&Eimage_id=<?php echo $Eimage_id; ?>" method="post">
<p>Keywords: <br /><textarea name="image_keys" rows="3" cols="15" maxlength="255"><?php echo  $Eimage_keywords['image_keywords']; ?> </textarea></p>
	 <p><input type="submit" value="Edit" /><input type="button" value="Go Back" onclick="history.back(-1)" /></p>
</form>

<div class="highslide-gallery">

<?php
if (empty($images)) {

	echo 'There are no images in this album';

} else {
	
	foreach ($images as $image) {
	 if ($Eimage_id != $image['id']) { 
	  echo '<a href="uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '" 
	           class="highslide" onclick="return hs.expand(this)">
	         <img src="uploads/thumbs/', $image['album'], '/', $image['id'], '.', $image['ext'], '" 
	              alt="Highslide JS" title="Uploaded ', date('D M Y / h:i', $image['timestamp']), '" />
	             <div class="highslide-caption"> Keywords: &nbsp', $image['keywords'],' </div>';
	}
}
	//print_r('uploads/'.$album_id.'/'.$image_id.'.'.$image_ext);
}

?>

</div>



<?php
include 'template/footer.php';
?>

</body>
</html>
